I'm going to try to address your point in a slightly different way from the answers that the other replies have given.
Because first I'd like to step back and ask what it means to define communism as an "ideology." When we talk about ideologies, we are usually talking about what values and morals we hold, and what things we believe to be true about the world. Whereas when we talk about communism, we are usually talking about a political project that people are organizing around in an attempt to bring a new kind of social/economic organization into the world.
People can come to support communism as a goal they wish to work towards because of their ideology, due to valuing things such as equality and fairness and so on, but communism itself is not a method of categorizing what things are good or bad in an ideological sense.
And if you self-identify as a communist, that tells me broadly speaking what goals you are working towards, but identifying as a communist by itself tells me very little about what your politics are. Because even though which political positions and political strategy you support is something that you can arrive at as a result of your ideology, what that political strategy actually is can and should change drastically depending on what conditions you are organizing a political movement under and how you can best adapt your political strategy to succeed in those conditions.
And that last consideration is what the majority of communist political theory is attempting to address. For example, here is what Marx has said on this (admittedly somewhat philosophical) point:
Communism is for us not a state of affairs which is to be established, an ideal to which reality [will] have to adjust itself. We call communism the real movement which abolishes the present state of things. The conditions of this movement result from the premises now in existence.
What this quote demonstrates is how Marx (and broadly speaking the communist movements who took inspiration from his work) viewed communism was not as a system of categorizing what things are good and what things are bad in order to create a communism checklist that you can use to evaluate how communist something is. Instead, he viewed communism and the purpose of political theory as something that can be used as a guide for developing an effective theory of change. He was much less concerned with answering ideological questions like "what does the ideal society look like" and prescribing those qualities as moral imperatives. Instead, he developed analytical tools that help to identify the way society is organized in terms of class conflicts and class interests, how that class conflict shapes and influences social organization, what kinds of leverage each class holds in society and how they use that leverage to protect/advance their shared class interests, and ultimately what ways we can use this understanding to develop a theory of change that can effectively influence this process of how societies are organized. So for Marx, the way he would define communism is in terms of how to use class analysis in order to create a political platform that represents the shared class interests we hold in common so that platform can be used rally workers together to organize political power and political leverage as a class, as well as using that analysis to develop the strategy and tactics necessary to advance those shared interests.
Neither the political platform of communists nor the strategy and tactics used to pursue that platform are things that are fixed in stone in a rigid or ideological way. Both are things that need to adapt as the as the situation you are organizing around changes. For example, what issues you organize around and prioritize as part of your political platform might change if, for example, the effects of climate change continue accumulating and threaten to make the planet we all live on unlivable.
As to the second point regarding strategy and tactics, it usually doesn't make sense to talk about things as being "incompatible" with communism. Usually it's more productive to talk about things being bad tactics for working towards communism. But what is and isn't bad tactics is highly situational. If you're developing a strategy to win a game you usually wouldn't say "Being aggressive is a bad tactic, you should play defensive to win." Well, I mean you certainly could develop a strategy that way, and it might even be generally accurate from a broad point of view. But a more carefully thought out strategy will usually consider what scenarios certain tactics should be applied, when it's good to go on offense vs when it's more advantageous to be defensive and let your opponent make a mistake or passively let their resources run out until they aren't a threat, and so on. You are constantly weighing your own advantages, your own limitations, what the expected risk vs reward tradeoff will be of a certain course of action, and weighing all of those factors against what your opponents are planning and what you expect them to do about your plans in response. And most of the information you are acting on will be imperfect, especially since your opponent is unlikely to give you the information you need to defeat them.
Now, after that long tangent about whether or not communism is an "ideology" and why whether we define it as an ideology matters, what does all of that have to do with whether or not patriotism is compatible with communism.
With the context and understanding I laid out above about how what makes something good/bad strategy is very dependent on the specific situation you are discussing, we can instead ask the question, "How is patriotism used/how does it manifest in different contexts, and what ends does that serve." Our common point of reference for where our understanding of what patriotism is comes from nationalist movements that grew in nations which became significant geopolitical entities through a legacy of colonialism and capitalist imperialism. These national projects have an identity that is intertwined with that colonial/imperialist legacy, and which is therefore difficult to separate from that legacy. This means that organizing around pride over that national identity will be inherently exclusionary to any groups who were victims of the legacy that you are celebrating and taking pride in. And indeed because of that context the way patriotism is often invoked is as a way for people in power who benefit from that legacy (as well as benefitting from the ongoing power/privilege that a given national project grants them) to deflect criticism or manufacture support for the past and ongoing harm caused by that national project. It does this by conflating criticism of the nation with criticism of an individual's identity, and by conflating "enemies of the nation" with "enemies of the people."
For those reasons, patriotism and national pride in the context of a colonial/imperialist nation is almost exclusively a tool for reactionaries. Denouncing and/or condemning national identity can make it harder to reach out to and organize with people who identify strongly with their nationality, and this is the argument Patsocs will use to say that you should embrace patriotism or else you are pushing away potential allies who will be turned off by an anti-patriotic message. But like I laid out above, the flipside to that argument is that the more you embrace patriotism the more you push away and exclude groups who were victims of your nation's legacy just to be more palatable to people who identify with and benefitted from that legacy in some way. And ultimately, when you are organizing you can eventually bring people around to supporting a more inclusive position through education and political outreach. But if you compromise on issues of systematic justice just to make it slightly easier to organize with people who have reactionary views with regards to patriotism, then ultimately you are creating an organization that marginalized groups on the other side of that national legacy will never feel safe participating in.
But national identity in the context of a colonized/formerly colonized nation takes on entirely different characteristics. In the context of colonization, national identity is used by the colonizing group to create mythologies about the cultural and racial deficiencies of the people who are being colonized in order to justify that occupation. Entire systems of schooling will be set up in occupied colonies to reinforce the colonist's world view, teaching children that their backwards and savage culture was hopelessly stuck in the stone ages until the more technologically advanced and philosophically enlightened colonizers came along to lift them out of the mud and be given the chance to serve a cause greater than themselves. That the colonizers graciously bestowed upon them colonial governments that were so much more sophisticated than the barbarism their people were accustomed to, that the colonizers were very magnanimous for giving structure and order to a savage and backward group of people who were too mentally or culturally deficient to look after themselves, and that in order to be a good colonial subject they must denounce their backwards culture, traditions, language, style of dress, values, beliefs, and mimic the culture of the colonizer instead.
The patterns of life imposed onto colonized people and the learned inferiority that is imposed and enforced by colonial rule and decades of social conditioning and indoctrination is an essential component for how colonialism and neo-colonialism reproduces itself an maintains political power over its colonized subjects. Forcing colonized people to internalize some version of this ideological framework is a powerful tool of psychological warfare. Dissent and resistance to colonial rule becomes much more rare if the colonized group believes this mythology, is made to feel shame about their heritage and culture, believes that they are worthy of being classified as a second class citizen in their own home, believes that they are better off under colonial rule, and so on. And this learned shame and learned inferiority can often be turned inward against a person's own family or community, causing people who have bought into this mythology to lash out against people in their communities who attempt to preserve their culture and their heritage with feelings of anger because "those kinds of backwards people who refuse to get with the times are the reason why we are looked down on as uncivilized savages."
This kind of social conditioning and cultural genocide is a powerful mechanism of control for colonial/neo-colonial governments. And the psychological/generational trauma inflicted as a result of this institutionalized oppression is devastating and demoralizing. And this context is what gives nationalism and national pride of a colonized people completely different characteristics. Creating a counter narrative in opposition to the mythology imposed by the colonizer can be incredibly powerful. It allows you proudly say that the self-serving mythology of the colonizer is a lie, that we are not culturally deficient savages that they wish to portray us as while they plunder our country and exploit our labor. That we have a heritage and history we can be proud of, that we have a strong community and shared struggle, and that we deserve to reclaim our own autonomy and govern ourselves instead of being ruled over by a colonial empire from half a world away.
In that context, nationalism and rallying people around national pride/national identity can be an incredibly powerful psychological tool for healing the morale of people who have been systematically oppressed and traumatized. It is a salve for a wounded and broken spirit to be told that you aren't deficient, that you do deserve better, and that all of the people who share in the community you belong to are willing help each other out to get through this struggle that we all find ourselves in so that we can all be free. Nationalism/patriotism in that context is a very powerful, and arguably necessary, force of liberation. And like others have commented, if you want to see this topic addressed much more thoroughly then you should read Fanon.
Now, a national liberation struggle is not necessarily going to result in communism. Whether a national liberation struggle pursues communism as its end goal depends at least in part on who is organizing and leading that struggle. But a national liberation struggle where nationalism is used as an organizing principle is certainly not incompatible with working towards communism, and in a colonized nation it is arguably a necessary first step and possibly the most effective organizing strategy available based on that context.
When people say that nationalism/patriotism is incompatible with communism, usually the point they're trying to make is that it is not possible to achieve communism in one country. That capitalism is a global system that imposes itself on the world via imperialism backed by the might of military empires. Therefore it can never be sufficient to overthrow capitalism in a single nation, because as long as the rest of the world is still capitalist your nation will be isolated, strangled, starved, and attacked until your liberation project falls apart and is dismantled so that it can be replaced with a capitalist government once again. Since a communist project cannot survive against capitalist onslaught in an isolated nation, any strategy for pursuing communism must involve an international component and support for liberation struggles around the world. But what this argument misses is that internationalism is not the opposite of nationalism. There's no reason why a national liberation struggle would be incompatible with international solidarity with other liberation struggles around the world. In fact, I would argue that it's fairly evident that you are unable to provide any effective support for international struggles until you are able to organize around resolving struggles at home first, and that national liberation struggles therefore create more opportunities for international solidarity. Which is just the basic idea of "It's impossible to fill another man's glass if your own pitcher is empty." In order to give solidarity to others you must first secure your own autonomy.
It's certainly true that the variety of nationalism/patriotism practiced in the imperial/colonial nations would certainly put up barriers to international solidarity, particularly with respect to people and nations who have suffered directly from that legacy. But that's why it's important to not take an analysis that's based on a specific frame of reference and clumsily apply that analysis in a different context by assuming that those conclusions are universal.
I'm going to try to address your point in a slightly different way from the answers that the other replies have given.
Because first I'd like to step back and ask what it means to define communism as an "ideology." When we talk about ideologies, we are usually talking about what values and morals we hold, and what things we believe to be true about the world. Whereas when we talk about communism, we are usually talking about a political project that people are organizing around in an attempt to bring a new kind of social/economic organization into the world.
People can come to support communism as a goal they wish to work towards because of their ideology, due to valuing things such as equality and fairness and so on, but communism itself is not a method of categorizing what things are good or bad in an ideological sense.
And if you self-identify as a communist, that tells me broadly speaking what goals you are working towards, but identifying as a communist by itself tells me very little about what your politics are. Because even though which political positions and political strategy you support is something that you can arrive at as a result of your ideology, what that political strategy actually is can and should change drastically depending on what conditions you are organizing a political movement under and how you can best adapt your political strategy to succeed in those conditions.
And that last consideration is what the majority of communist political theory is attempting to address. For example, here is what Marx has said on this (admittedly somewhat philosophical) point:
What this quote demonstrates is how Marx (and broadly speaking the communist movements who took inspiration from his work) viewed communism was not as a system of categorizing what things are good and what things are bad in order to create a communism checklist that you can use to evaluate how communist something is. Instead, he viewed communism and the purpose of political theory as something that can be used as a guide for developing an effective theory of change. He was much less concerned with answering ideological questions like "what does the ideal society look like" and prescribing those qualities as moral imperatives. Instead, he developed analytical tools that help to identify the way society is organized in terms of class conflicts and class interests, how that class conflict shapes and influences social organization, what kinds of leverage each class holds in society and how they use that leverage to protect/advance their shared class interests, and ultimately what ways we can use this understanding to develop a theory of change that can effectively influence this process of how societies are organized. So for Marx, the way he would define communism is in terms of how to use class analysis in order to create a political platform that represents the shared class interests we hold in common so that platform can be used rally workers together to organize political power and political leverage as a class, as well as using that analysis to develop the strategy and tactics necessary to advance those shared interests.
Neither the political platform of communists nor the strategy and tactics used to pursue that platform are things that are fixed in stone in a rigid or ideological way. Both are things that need to adapt as the as the situation you are organizing around changes. For example, what issues you organize around and prioritize as part of your political platform might change if, for example, the effects of climate change continue accumulating and threaten to make the planet we all live on unlivable.
As to the second point regarding strategy and tactics, it usually doesn't make sense to talk about things as being "incompatible" with communism. Usually it's more productive to talk about things being bad tactics for working towards communism. But what is and isn't bad tactics is highly situational. If you're developing a strategy to win a game you usually wouldn't say "Being aggressive is a bad tactic, you should play defensive to win." Well, I mean you certainly could develop a strategy that way, and it might even be generally accurate from a broad point of view. But a more carefully thought out strategy will usually consider what scenarios certain tactics should be applied, when it's good to go on offense vs when it's more advantageous to be defensive and let your opponent make a mistake or passively let their resources run out until they aren't a threat, and so on. You are constantly weighing your own advantages, your own limitations, what the expected risk vs reward tradeoff will be of a certain course of action, and weighing all of those factors against what your opponents are planning and what you expect them to do about your plans in response. And most of the information you are acting on will be imperfect, especially since your opponent is unlikely to give you the information you need to defeat them.
(Continued in reply)
Now, after that long tangent about whether or not communism is an "ideology" and why whether we define it as an ideology matters, what does all of that have to do with whether or not patriotism is compatible with communism.
With the context and understanding I laid out above about how what makes something good/bad strategy is very dependent on the specific situation you are discussing, we can instead ask the question, "How is patriotism used/how does it manifest in different contexts, and what ends does that serve." Our common point of reference for where our understanding of what patriotism is comes from nationalist movements that grew in nations which became significant geopolitical entities through a legacy of colonialism and capitalist imperialism. These national projects have an identity that is intertwined with that colonial/imperialist legacy, and which is therefore difficult to separate from that legacy. This means that organizing around pride over that national identity will be inherently exclusionary to any groups who were victims of the legacy that you are celebrating and taking pride in. And indeed because of that context the way patriotism is often invoked is as a way for people in power who benefit from that legacy (as well as benefitting from the ongoing power/privilege that a given national project grants them) to deflect criticism or manufacture support for the past and ongoing harm caused by that national project. It does this by conflating criticism of the nation with criticism of an individual's identity, and by conflating "enemies of the nation" with "enemies of the people."
For those reasons, patriotism and national pride in the context of a colonial/imperialist nation is almost exclusively a tool for reactionaries. Denouncing and/or condemning national identity can make it harder to reach out to and organize with people who identify strongly with their nationality, and this is the argument Patsocs will use to say that you should embrace patriotism or else you are pushing away potential allies who will be turned off by an anti-patriotic message. But like I laid out above, the flipside to that argument is that the more you embrace patriotism the more you push away and exclude groups who were victims of your nation's legacy just to be more palatable to people who identify with and benefitted from that legacy in some way. And ultimately, when you are organizing you can eventually bring people around to supporting a more inclusive position through education and political outreach. But if you compromise on issues of systematic justice just to make it slightly easier to organize with people who have reactionary views with regards to patriotism, then ultimately you are creating an organization that marginalized groups on the other side of that national legacy will never feel safe participating in.
But national identity in the context of a colonized/formerly colonized nation takes on entirely different characteristics. In the context of colonization, national identity is used by the colonizing group to create mythologies about the cultural and racial deficiencies of the people who are being colonized in order to justify that occupation. Entire systems of schooling will be set up in occupied colonies to reinforce the colonist's world view, teaching children that their backwards and savage culture was hopelessly stuck in the stone ages until the more technologically advanced and philosophically enlightened colonizers came along to lift them out of the mud and be given the chance to serve a cause greater than themselves. That the colonizers graciously bestowed upon them colonial governments that were so much more sophisticated than the barbarism their people were accustomed to, that the colonizers were very magnanimous for giving structure and order to a savage and backward group of people who were too mentally or culturally deficient to look after themselves, and that in order to be a good colonial subject they must denounce their backwards culture, traditions, language, style of dress, values, beliefs, and mimic the culture of the colonizer instead.
The patterns of life imposed onto colonized people and the learned inferiority that is imposed and enforced by colonial rule and decades of social conditioning and indoctrination is an essential component for how colonialism and neo-colonialism reproduces itself an maintains political power over its colonized subjects. Forcing colonized people to internalize some version of this ideological framework is a powerful tool of psychological warfare. Dissent and resistance to colonial rule becomes much more rare if the colonized group believes this mythology, is made to feel shame about their heritage and culture, believes that they are worthy of being classified as a second class citizen in their own home, believes that they are better off under colonial rule, and so on. And this learned shame and learned inferiority can often be turned inward against a person's own family or community, causing people who have bought into this mythology to lash out against people in their communities who attempt to preserve their culture and their heritage with feelings of anger because "those kinds of backwards people who refuse to get with the times are the reason why we are looked down on as uncivilized savages."
This kind of social conditioning and cultural genocide is a powerful mechanism of control for colonial/neo-colonial governments. And the psychological/generational trauma inflicted as a result of this institutionalized oppression is devastating and demoralizing. And this context is what gives nationalism and national pride of a colonized people completely different characteristics. Creating a counter narrative in opposition to the mythology imposed by the colonizer can be incredibly powerful. It allows you proudly say that the self-serving mythology of the colonizer is a lie, that we are not culturally deficient savages that they wish to portray us as while they plunder our country and exploit our labor. That we have a heritage and history we can be proud of, that we have a strong community and shared struggle, and that we deserve to reclaim our own autonomy and govern ourselves instead of being ruled over by a colonial empire from half a world away.
In that context, nationalism and rallying people around national pride/national identity can be an incredibly powerful psychological tool for healing the morale of people who have been systematically oppressed and traumatized. It is a salve for a wounded and broken spirit to be told that you aren't deficient, that you do deserve better, and that all of the people who share in the community you belong to are willing help each other out to get through this struggle that we all find ourselves in so that we can all be free. Nationalism/patriotism in that context is a very powerful, and arguably necessary, force of liberation. And like others have commented, if you want to see this topic addressed much more thoroughly then you should read Fanon.
Now, a national liberation struggle is not necessarily going to result in communism. Whether a national liberation struggle pursues communism as its end goal depends at least in part on who is organizing and leading that struggle. But a national liberation struggle where nationalism is used as an organizing principle is certainly not incompatible with working towards communism, and in a colonized nation it is arguably a necessary first step and possibly the most effective organizing strategy available based on that context.
When people say that nationalism/patriotism is incompatible with communism, usually the point they're trying to make is that it is not possible to achieve communism in one country. That capitalism is a global system that imposes itself on the world via imperialism backed by the might of military empires. Therefore it can never be sufficient to overthrow capitalism in a single nation, because as long as the rest of the world is still capitalist your nation will be isolated, strangled, starved, and attacked until your liberation project falls apart and is dismantled so that it can be replaced with a capitalist government once again. Since a communist project cannot survive against capitalist onslaught in an isolated nation, any strategy for pursuing communism must involve an international component and support for liberation struggles around the world. But what this argument misses is that internationalism is not the opposite of nationalism. There's no reason why a national liberation struggle would be incompatible with international solidarity with other liberation struggles around the world. In fact, I would argue that it's fairly evident that you are unable to provide any effective support for international struggles until you are able to organize around resolving struggles at home first, and that national liberation struggles therefore create more opportunities for international solidarity. Which is just the basic idea of "It's impossible to fill another man's glass if your own pitcher is empty." In order to give solidarity to others you must first secure your own autonomy.
It's certainly true that the variety of nationalism/patriotism practiced in the imperial/colonial nations would certainly put up barriers to international solidarity, particularly with respect to people and nations who have suffered directly from that legacy. But that's why it's important to not take an analysis that's based on a specific frame of reference and clumsily apply that analysis in a different context by assuming that those conclusions are universal.