We consider the offline and online versions of a bin packing problem called bin packing with conflicts. Given a set of items $V=\{ 1,2,\dots,n\}$ with sizes $s_1,s_2,\dots,s_n\in[0,1]$ and a conflict graph $G=(V,E)$, the goal is to find a partition of the items into independent sets of $G$, where the total size of items in each independent set is at most 1 so that the number of independent sets in the partition is minimized. This problem is clearly a generalization of both the classical (one-dimensional) bin packing problem where $E=\emptyset$ and of the graph coloring problem where $s_i=0$ for all $i=1,2,\dots,n$. Since coloring problems on general graphs are hard to approximate, following previous work, we study the problem on specific graph classes. For the offline version, we design improved approximation algorithms for perfect graphs and other special classes of graphs: These are a $\frac52=2.5$-approximation algorithm for perfect graphs; a $\frac73\approx2.33333$-approximation algorithm for a subclass of perfect graphs, which contains interval graphs and chordal graphs; and a $\frac74=1.75$-approximation for algorithm bipartite graphs. For the online problem on interval graphs, we design a 4.7-competitive algorithm and show a lower bound of $\frac{155}{36}\approx4.30556$ on the competitive ratio of any algorithm. To derive the last lower bound, we introduce the first lower bound on the asymptotic competitive ratio of any online bin packing algorithm with known optimal value, which is $\frac{47}{36}\approx1.30556$.